[Top][All Lists]

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

Re: minimal hack to classpath for ORP 1.0.9

From: Eric Blake
Subject: Re: minimal hack to classpath for ORP 1.0.9
Date: Mon, 25 Mar 2002 22:51:06 -0700

Fred Gray wrote:
> 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.

Man, those dependencies are annoying.  Would using StrictMath.abs() in
place of Math.abs() work, since StrictMath doesn't use native methods? 
Then again, inlining the check for absolute value saves a method call. 
I'll go ahead and apply that patch you suggested.

> 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.

I thought, in my analysis yesterday, that System.isWordsBigEndian
wouldn't be called until after System.loadLibrary("javalang"), called in
Object.<clinit>, has completed.  But thinking about it more, I guess you
are right - Object.<clinit> invokes the System class initializer, which
then executes to completion before returning to Object.<clinit>; and
System.<clinit> does use the native method.  My patch yesterday just
deleted the line in System which called loadLibrary("javalang"),
thinking it was redundant; I guess I was wrong, so I'll add it back in
and document it this time.

> The last part of this message is a patch against the pristine ORP 1.0.9 
> release
> @@ -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 },

The last three methods in this section of the patch have been renamed
java_lang_System_setErr0, setIn0, and setOut0, because there must be a
security check in Java first.  You should probably fix those as well, to
avoid another linkage error.

This signature intentionally left boring.

Eric Blake             address@hidden
  BYU student, free software programmer

reply via email to

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