I think I've figured out the minimal hack to the current classpath CVS to
work with ORP 1.0.9 (at least for programs of the complexity of "Hello world").
Hopefully, this will give the people who understand ORP some ideas on how
to fix things up properly.

Issue 1: Calling methods in java.lang.System from the constructor of 
java.lang.Runtime seems to cause a crash.  Workaround:

Index: vm/reference/java/lang/Runtime.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/Runtime.java,v
retrieving revision 1.15
diff -u -r1.15 Runtime.java
--- vm/reference/java/lang/Runtime.java 22 Mar 2002 21:25:20 -0000      1.15
+++ vm/reference/java/lang/Runtime.java 24 Mar 2002 23:44:57 -0000
@@ -95,6 +95,14 @@
   {
     if (current != null)
       throw new InternalError("Attempt to recreate Runtime");
+
+    /*
+     * HACKHACK: it seems that calling any System.* methods at this point
+     * crashes ORP 1.0.9, so we force the library path to ".".
+     */
+    libpath = new String[] { "." };
+ 
+/* 
     // XXX Does this need special privileges?
     String path = System.getProperty("java.library.path");
     if (path == null)
@@ -109,6 +117,7 @@
         for (int i = 0; i < libpath.length; i++)
           libpath[i] = t.nextToken();
       }
+*/
   }
 
   /**
===================================================================

Issue 2: Calling clone() on an array in String.getCharArray() causes a
linking error when the method is compiled.  As an aside, I'm at least a
little interested in knowing why (char []).clone() is thought to be faster
than System.arraycopy().  Workaround:

Index: java/lang/String.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/String.java,v
retrieving revision 1.42
diff -u -r1.42 String.java
--- java/lang/String.java       21 Mar 2002 22:30:08 -0000      1.42
+++ java/lang/String.java       24 Mar 2002 23:50:17 -0000
@@ -1415,8 +1415,14 @@
    */
   public char[] toCharArray()
   {
+    /*
+     * HACKHACK: it seems that using clone() on an array at this point
+     * causes ORP 1.0.9 to crash, so we eliminate this optimization.
+     * 
+/*     
     if (count == value.length)
       return (char[]) value.clone();
+*/
     char[] copy = new char[count];
     System.arraycopy(value, offset, copy, 0, count);
     return copy;
===================================================================

Issue 3: It isn't necessary to make any of my simple test programs work, but
this patch to ORP to deal with the re-ordering of fields in java.lang.String
will almost certainly be required for something:

===================================================================
diff -u orp-1.0.9/base_natives/gnu_classpath/include/gnu_specific.h 
orp-1.0.9-hacked/base_natives/gnu_classpath/include/gnu_specific.h 
--- orp-1.0.9/base_natives/gnu_classpath/include/gnu_specific.h Wed Jan 16 23:49:40 
2002
+++ orp-1.0.9-hacked/base_natives/gnu_classpath/include/gnu_specific.h  Mon Mar 18 
+19:53:39 2002
@@ -13,5 +13,6 @@
 
     JavaArrayOfChar *value;
     int32            count;
+    int32            cachedHashCode;
     int32            offset;
 } Classpath_Java_java_lang_String;
===================================================================

Thanks very much for some great free software,

-- Fred Gray

_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to