classpath
[Top][All Lists]
Advanced

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

Re: minimal hack to classpath for ORP 1.0.9


From: Fred Gray
Subject: Re: minimal hack to classpath for ORP 1.0.9
Date: Mon, 25 Mar 2002 23:28:51 -0600
User-agent: Mutt/1.2.5i

On Mon, Mar 25, 2002 at 12:51:22AM -0700, Eric Blake wrote:
> 
> I did some shuffling and analysis, and I think the latest version in
> Classpath has a safe bootstrap sequence.  Can you please test it for
> me? 
>

Thanks for all of your quick work.  It _almost_ solved the problem.

I did a cvs update to get your changes, and I copied the native method
insertSystemProperties() from VMSystem to Runtime.  ORP still crashed.

>    *    Dictionary, Hashtable, and Properties have no dependencies

This is the where the chain broke.  Adding the properties to the Hashtable
calls Hashtable.hash(), which calls Math.abs(). That causes the static
initializer for Math to be run, and it calls System.loadLibrary().  
Kaboom.

The simple fix for this one is to avoid calling Math.abs().  A patch 
to do that appears below.

The last problem is that the native method System.isWordsBigEndian() 
is needed by the static initializer for System before the Classpath java.lang 
JNI library is loaded.  I enabled ORP's built-in version of this method
(which takes the super-portable "return false" approach to the problem).  
At long last, "Hello world!" appeared.  

The last part of this message is a patch against the pristine ORP 1.0.9 release
with all of the changes I had to make to get it to work.  (It includes the 
patch in Classpath's resource/orp-1.0.9.patch .)

Thanks again for all of your help,

-- Fred Gray

===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Hashtable.java,v
retrieving revision 1.23
diff -u -r1.23 Hashtable.java
--- Hashtable.java      25 Mar 2002 07:54:38 -0000      1.23
+++ Hashtable.java      26 Mar 2002 04:24:14 -0000
@@ -821,7 +821,12 @@
    */
   private int hash(Object key)
   {
-    return Math.abs(key.hashCode() % buckets.length);
+    // NOTE: using Math.abs() here, attractive as it is, leads to a
+    // bootstrapping problem.
+    int hashVal = key.hashCode() % buckets.length;
+    if(hashVal < 0)
+      hashVal = -hashVal; 
+    return hashVal;
   }
 
   /**
===================================================================

===================================================================
diff -ur orp-1.0.9-pristine/arch/ia32/base/root_set_enum_ia32.cpp 
orp-1.0.9/arch/ia32/base/root_set_enum_ia32.cpp
--- orp-1.0.9-pristine/arch/ia32/base/root_set_enum_ia32.cpp    Wed Jan 16 
23:49:40 2002
+++ orp-1.0.9/arch/ia32/base/root_set_enum_ia32.cpp     Sun Mar 24 17:14:46 2002
@@ -35,9 +35,6 @@
 #include "../x86/x86.h"
 
 #ifdef ORP_POSIX
-#ifdef __linux__
-#include <asm/spinlock.h>
-#endif
 #include "platform2.h"
 #endif
 
diff -ur orp-1.0.9-pristine/base_natives/common_olv2/mon_enter_exit.cpp 
orp-1.0.9/base_natives/common_olv2/mon_enter_exit.cpp
--- orp-1.0.9-pristine/base_natives/common_olv2/mon_enter_exit.cpp      Wed Jan 
16 23:49:40 2002
+++ orp-1.0.9/base_natives/common_olv2/mon_enter_exit.cpp       Sun Mar 24 
17:14:46 2002
@@ -294,7 +294,7 @@
 #else
                "nop;nop;nop"
 #endif
-               ::: "memory"
+               : : : "memory"
        );
 
 #else
diff -ur orp-1.0.9-pristine/base_natives/gnu_classpath/find_natives_array.cpp 
orp-1.0.9/base_natives/gnu_classpath/find_natives_array.cpp
--- orp-1.0.9-pristine/base_natives/gnu_classpath/find_natives_array.cpp        
Wed Jan 16 23:49:40 2002
+++ orp-1.0.9/base_natives/gnu_classpath/find_natives_array.cpp Mon Mar 25 
22:43:30 2002
@@ -122,6 +122,7 @@
        { "java_lang_Runtime_freeMemory", (void *) 
Java_java_lang_Runtime_freeMemory, NI_IS_JNI },
        { "java_lang_Runtime_gc", (void *) Java_java_lang_Runtime_gc, NI_IS_JNI 
},
        { "java_lang_Runtime_getLibraryPath", (void *) 
Java_java_lang_Runtime_getLibraryPath, NI_IS_JNI },
+       { "java_lang_Runtime_insertSystemProperties", (void *) 
Java_java_lang_Runtime_insertSystemProperties, NI_IS_JNI },
  //loadLibrary is just for new classpath
 #ifndef OLD_VERSION_CLASSPATH
     { "java_lang_Runtime_loadLibrary", (void 
*)Java_java_lang_Runtime_loadLibrary, NI_IS_JNI },
@@ -139,6 +140,7 @@
 
 //java.lang.System native methods
     { "java_lang_System_arraycopy", (void  *)java_lang_System_arraycopy,  
NI_IS_RNI },
+    { "java_lang_System_isWordsBigEndian", (void *) 
Java_java_lang_System_isWordsBigEndian, NI_IS_JNI },
 
 //java.lang.Thread native methods
     { "java_lang_Thread_countStackFrames", (void  
*)java_lang_Thread_countStackFrames,  NI_IS_RNI },
@@ -344,7 +346,6 @@
 
        //{ "java_lang_System_currentTimeMillis", (void *) 
Java_java_lang_System_currentTimeMillis, NI_IS_JNI },
        { "java_lang_System_currentTimeMillis", (void *) 
Java_java_lang_System_currentTimeMillis_no_extra_args, NI_IS_DIRECT },
-    { "java_lang_System_isWordsBigEndian", (void *) 
Java_java_lang_System_isWordsBigEndian, NI_IS_JNI },
        { "java_lang_System_setErr", (void *) Java_java_lang_System_setErr, 
NI_IS_JNI },
        { "java_lang_System_setIn", (void *) Java_java_lang_System_setIn, 
NI_IS_JNI },
        { "java_lang_System_setOut", (void *) Java_java_lang_System_setOut, 
NI_IS_JNI },
diff -ur orp-1.0.9-pristine/base_natives/gnu_classpath/include/gnu_specific.h 
orp-1.0.9/base_natives/gnu_classpath/include/gnu_specific.h
--- orp-1.0.9-pristine/base_natives/gnu_classpath/include/gnu_specific.h        
Wed Jan 16 23:49:40 2002
+++ orp-1.0.9/base_natives/gnu_classpath/include/gnu_specific.h Sun Mar 24 
17:31:21 2002
@@ -13,5 +13,6 @@
 
     JavaArrayOfChar *value;
     int32            count;
+    int32            cachedHashCode;
     int32            offset;
 } Classpath_Java_java_lang_String;
diff -ur 
orp-1.0.9-pristine/base_natives/gnu_classpath/include/java_lang_Runtime.h 
orp-1.0.9/base_natives/gnu_classpath/include/java_lang_Runtime.h
--- orp-1.0.9-pristine/base_natives/gnu_classpath/include/java_lang_Runtime.h   
Wed Jan 16 23:49:40 2002
+++ orp-1.0.9/base_natives/gnu_classpath/include/java_lang_Runtime.h    Mon Mar 
25 22:43:30 2002
@@ -128,6 +128,14 @@
 JNIEXPORT void JNICALL Java_java_lang_Runtime_loadLibrary
   (JNIEnv *jenv, jobject jobj , jstring lib_name);
 
+// for even newer Classpath
+/*
+ * Class:     java_lang_Runtime
+ * Method:    insertSystemProperties
+ * Signature: (Ljava/util/Properties;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_Runtime_insertSystemProperties
+  (JNIEnv *, jclass, jobject);
 
 #ifdef __cplusplus
 }
diff -ur orp-1.0.9-pristine/base_natives/gnu_classpath/java_lang_Runtime.cpp 
orp-1.0.9/base_natives/gnu_classpath/java_lang_Runtime.cpp
--- orp-1.0.9-pristine/base_natives/gnu_classpath/java_lang_Runtime.cpp Wed Jan 
16 23:49:40 2002
+++ orp-1.0.9/base_natives/gnu_classpath/java_lang_Runtime.cpp  Mon Mar 25 
22:43:30 2002
@@ -26,10 +26,14 @@
 #endif
 #ifdef ORP_NT
 #include <winbase.h>
+#else
+#include <unistd.h>
+#include <sys/utsname.h>
 #endif
 
 #include "java_lang_Object.h"
 #include "java_lang_Runtime.h"
+#include "properties.h"
 #include "gc_for_orp.h"
 #include "gnu_specific.h"
 
@@ -473,4 +477,96 @@
        return jl_str;
 
 } // Java_java_lang_String_intern
+
+/*
+ * Class:     Runtime
+ * Method:    insertSystemProperties
+ * Signature: (Ljava/util/Properties;)V
+ */
+
+JNIEXPORT void JNICALL Java_java_lang_Runtime_insertSystemProperties(JNIEnv 
*jenv, jclass clazz, jobject pProperties)
+{
+
+       // Now, insert all the default properties.
+
+    char local[_MAX_PATH];
+
+    void __stdcall PropPut(JNIEnv *env, jobject pObj, char *pProp, char *pVal);
+
+    PropPut(jenv, pProperties, "user.language", "en");
+    PropPut(jenv, pProperties, "java.home", ".");
+    PropPut(jenv, pProperties, "java.version", "GNU Classpath 0.02");
+    PropPut(jenv, pProperties, "java.vendor", "GNU/FSF");
+       PropPut(jenv, pProperties, "java.vm.name", "Open Runtime Platform");
+    PropPut(jenv, pProperties, "java.vm.version", "1.09");
+    PropPut(jenv, pProperties, "java.vm.vendor", "Intel MRL");
+
+#ifdef ORP_NT
+    PropPut(jenv, pProperties, "file.separator", "\\");
+#else
+    PropPut(jenv, pProperties, "file.separator", "/");
+#endif
+
+    PropPut(jenv, pProperties, "line.separator", "\n");
+    PropPut(jenv, pProperties, "user.region", "US");
+    PropPut(jenv, pProperties, "file.encoding", "8859_1");
+    PropPut(jenv, pProperties, "java.vendor", "Intel MRL");
+    PropPut(jenv, pProperties, "user.name", "ssubram5");
+    PropPut(jenv, pProperties, "os.arch", "x86");
+
+#ifdef ORP_NT
+       OSVERSIONINFO vi;
+       vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+       if(!GetVersionEx(&vi)){
+               PropPut(jenv, pProperties, "os.name", "Windows NT");
+               PropPut(jenv, pProperties, "os.version", "4.0");
+       }else{
+               assert(vi.dwPlatformId == VER_PLATFORM_WIN32_NT);
+               if(vi.dwMajorVersion < 5)
+                       PropPut(jenv, pProperties, "os.name", "Windows NT");
+               else
+                       PropPut(jenv, pProperties, "os.name", "Windows 2000");
+               char buf[20];
+               sprintf(buf, "%d.%d", vi.dwMajorVersion, vi.dwMinorVersion);
+               PropPut(jenv, pProperties, "os.version", buf);
+       }
+#else
+       struct utsname buf;
+       if(uname(&buf)){
+               PropPut(jenv, pProperties, "os.name", "Linux");
+               PropPut(jenv, pProperties, "os.version", "6.1");
+       }else{
+               PropPut(jenv, pProperties, "os.name", buf.sysname);
+               PropPut(jenv, pProperties, "os.version", buf.release);
+       }
+#endif
+
+    PropPut(jenv, pProperties, "java.vendor.url", "http://www.intel.com/";);
+#ifdef ORP_NT
+    PropPut(jenv, pProperties, "user.dir", _getcwd(local, _MAX_PATH));
+       char *tmpdir = getenv("TEMP");
+       PropPut(jenv, pProperties, "java.tmpdir", tmpdir != NULL ? tmpdir: ".");
+#else
+    PropPut(jenv, pProperties, "user.dir", getcwd(local, _MAX_PATH));
+       PropPut(jenv, pProperties, "java.tmpdir", "/tmp");
+#endif
+    PropPut(jenv, pProperties, "java.class.path", 
ORP_Global_State::loader_env->classpath);
+    PropPut(jenv, pProperties, "java.class.version", "45.3");
+
+#ifdef ORP_NT
+    PropPut(jenv, pProperties, "path.separator", ";");
+#else
+    PropPut(jenv, pProperties, "path.separator", ":");
+#endif
+
+    PropPut(jenv, pProperties, "user.home", ".");
+
+//ORP specified/APP specified properties are supported here.
+    Properties::Iterator *iterator = 
ORP_Global_State::loader_env->properties.getIterator();
+       const Prop_entry *next = NULL;
+       while(next = iterator->next()){
+               PropPut(jenv, pProperties, next->key, 
((Prop_String*)next->value)->value);
+       }
+       
+} //Java_java_lang_Runtime_insertSystemProperties
===================================================================



reply via email to

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