Question: System.initializeSystemClass()
Ulf Zibis
Ulf.Zibis at gmx.de
Sun Jan 11 08:19:13 PST 2009
Hi,
regarding my project https://java-nio-charset-enhanced.dev.java.net/ I
am run into a problem:
When System.initializeSystemClass() is opening the the standard I/O
streams out and err, new PrintStream() creates new StreamEncoder which
needs to access Charset.defaultCharset().
At this point I get UnsatisfiedLinkError, because my implementation of
FastCharsetProvider class need to load mapping data from file system via
getClass().getResourceAsStream(canonicalName+".dat"), and zip library is
not loaded at this time:
class System {
...
static void initializeSystemClass() {
...
setIn0(new BufferedInputStream(fdIn));
setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128),
true));
setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128),
true));
// Load the zip library now in order to keep java.util.zip.ZipFile
// from trying to use itself to load this library later.
loadLibrary("zip");
...
}
...
}
MY QUESTION:
Is there any risk, to load zip library before opening the standard I/O
streams out and err ?
class System {
...
static void initializeSystemClass() {
...
setIn0(new BufferedInputStream(fdIn));
// PrintStream() creates new sun.io.cs.StreamEncoder which
// needs to load charset mapping data from rt.jar via
// sun.io.cs.FastCharsetProvider#getClass().getResourceAsStream()
// So load the zip library now in order to keep
java.util.zip.ZipFile
// from trying to use itself to load this library later.
loadLibrary("zip");
setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128),
true));
setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128),
true));
...
}
...
}
The only problem I see is, that if loadLibrary("zip") fails, the
exception messages can't be propagated to standard err stream.
What you guys do you think?
-Ulf
More information about the hotspot-dev
mailing list