RE: classpath initialization

2003-10-14 Thread David Holmes
Joseph,

> My problem is that the call stack during initialization of
> the System class I looks something like
...
> The last line causes an exception, since the static member
> properties isn't initialized yet.

Initialization is quite tricky. Basically your VMClassloader is making
assumptions about the initialization state of the system that are not
valid in the default initialization sequence.

We encountered a similar problem (and others). If we tried to create a
String from a byte[] we needed the EncodingManager which needed to
access a system property but System had not reached a point in
initialization where you could call getProperty. I actually posted an
email to the list about this a couple of weeks ago - which I've
attached below. We had to change the way System.java behaved during
initialization. (Somewhat related we also have to take pains to avoid
referencing String literals early in the VM startup process because
they can't be interned at that point.)

David Holmes


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
David Holmes
Sent: Thursday, 25 September 2003 2:21 PM
To: classpath
Subject: File encodings and initialization sequence


Just wanted to share experiences with the initialization sequence and
trying to resolve the character encoding problem.

To fill in various system properties in Runtime we use native code to
get C char arrays with output from things like uname, cwd etc. These
are returned as Java byte arrays and have to be converted to Java
Strings. The correct way to do this seemed to be to use the
String(byte[]) constructor and ensure the corrected decoder was used.
But this wasn't possible because the EncodingManager. uses
System.getProperty and that would be called before System. had
actually initialized its properties object. Hence we'd get a
NullPointerException.

To fix this Runtime now forces System to use it's properties object
until System. reaches the point were it clones runtime's
properties object. Before I set any system properties I now extract
the default character set name, acquired via native code, and use that
to set the file.encoding property. Then I set all the encoding alias
properties in case the default charset name is actually an alias.
After that I can construct Strings from byte[] using the right
decoding.

I'm curious how others have dealt with this issue. I'm no expert on
character-set/locale/internationalization issues.

Related to this problem, I also found out that any exception that
occurs prior to the point where System clones the runtime properties
will cause recursive exceptions because Throwable. also uses
System.getProperty, which will throw NPE. I'd be tempted to have any
static initialization code that needs a system property to read it
direct from Runtime.properties - though of course that only works for
classes in java.lang.

Cheers,
David Holmes




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


Fwd: Alan Moore assigns past and future changes

2003-10-14 Thread Brian Jones
--- Begin Message ---

cc - maintainer
name: Alan Moore
email: [EMAIL PROTECTED]

Which files have you changed so far, and which new files have you
written so far?
changed: RE.java, REException.java,
new: MessagesBundle.properties


--- End Message ---


-- 
Brian Jones <[EMAIL PROTECTED]>
___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath


classpath initialization

2003-10-14 Thread Joseph Wenninger
Hi

I'm trying to use an unmodified classpath (0.06). I already have
something working with a modified one.

My problem is that the call stack during initialization of the System
class I looks something like 

LOG:  called: java/lang/System.()V()
LOG:   called:
java/lang/System.loadLibrary(Ljava/lang/String;)V(405c8488)
LOG: called: java/lang/Runtime.getRuntime()Ljava/lang/Runtime;()
LOG: finished:
java/lang/Runtime.getRuntime()Ljava/lang/Runtime;->0x8420fd8
LOG: called:
java/lang/Runtime.loadLibrary(Ljava/lang/String;)V(8420fd8, 405c8488)
LOG: called:
java/lang/VMSecurityManager.currentClassLoader()Ljava/lang/ClassLoader;()
LOG: called: java/lang/ClassLoader.()V()
LOG: compiler_addinitclass: java/lang/VMClassLoader
LOG: called:
java/lang/VMClassLoader.getSystemClassLoader()Ljava/lang/ClassLoader;()
LOG: called:
java/lang/System.getProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;(405cb500,
 405cb578)
()Vhttp://mail.gnu.org/mailman/listinfo/classpath


Re: OSX port of classpath

2003-10-14 Thread Tom Tromey
> "Chris" == Chris Hoffmann <[EMAIL PROTECTED]> writes:

Chris> Any chance these can be folded into classpath 0.07?

Probably.

Chris> +++ classpath/native/fdlibm/ieeefp.h Fri Oct  3 11:17:44 2003

This part looks fine to me.  It might be better to put this check in
with the other OS checks when __PPC__ is defined, though (that's what
we did in libgcj :-).

Could you do this and write a ChangeLog entry?  I'll check this bit
in.

Chris> +  INIT_FIELD ("in", ((long long)0));
Chris> +  INIT_FIELD ("out", ((long long)1));
Chris> +  INIT_FIELD ("err", ((long long)2));

Why did you need this?

Chris> +#ifndef O_SYNC
Chris> +#undef TARGET_NATIVE_FILE_FILEFLAG_SYNC
Chris> +#define TARGET_NATIVE_FILE_FILEFLAG_SYNC O_FSYNC
Chris> +#endif

This looks like something that should go in one of the target headers.

Chris> +#ifdef __MACH__
Chris> +typedef intsocklen_t;   
Chris> +#endif

Likewise.


BTW, I saw this in FileDescriptor.c:

#ifdef O_BINARY
  flags |= TARGET_NATIVE_FILE_FILEFLAG_BINARY;
#endif

That looks weird to me.  It would be cleaner to just always include
this, and let targets define it to 0.

Also, the target headers I looked at don't conform to the GNU coding
standard.

Tom


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