This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Re: java.text patches
Tom Tromey wrote:
> Bryce> Here's three micellanious patches for the java.text format
> Bryce> classes.
>
> I never replied to this -- oops.
>
> Bryce> 1) a tenative fix for libgcj/38 - this fixes the circular
> Bryce> initializer dependency by delaying the construction
> Bryce> nonLocalizedSymbols until it is actually needed.
>
> I still don't understand this bug. Why does this circular dependency
> matter? Shouldn't class initialization work in the presence of
> circular dependencies?
Circular initializer dependency in itself should work, but in this case
one of the initializers actually depends on another having already been
initialized. Perhaps I'm not explaining it well - this test code is (a
very simplified version of) what is happening in DecimalFormat:
public class Main
{
public static void main(String args[])
{
A a = new A();
}
}
public class A
{
private static final B b = new B();
A()
{
System.out.println("A constructed...");
}
String getString()
{
return b.getString();
}
}
public class B
{
private String somestring = "foo";
B()
{
System.out.println("B constructed...");
A a = new A();
System.out.println(a.getString());
}
String getString()
{
return somestring;
}
}
On JDK 1.1.8, this throws an ExceptionInInitializerError. On gcj, it
aborts somewhere in the class initialization code.
I've explained the DecimalFormat problem more completely in the PR:
http://sourceware.cygnus.com/ml/java-prs/1999-q3/msg00045.html. The
initialization "chain" here is quite long, and DecimalFormat may possibly
not be the best place to fix the dependency.
> Bryce> 2) The (String pattern) constructor for MessageFormat just
> Bryce> calls applyPattern, which assumes that a locale has been
> Bryce> set. It needs to set the default locale before calling
> Bryce> applyPattern, or a NullPointerException occurs.
>
> Bryce> 3) NumberFormat throws a ClassCastException if the object being
> Bryce> formatted is not actually a Number. It should throw an
> Bryce> IllegialArgumentException. Verfified against JDK behaviour.
>
> Please check these two in.
Done.
regards
[ bryce ]