If an exception occurs during sys.pod load then this problem is not reported correctly.
In Sys.java:
// load sys pod
SysPod = Pod.doFind("sys", true, null, null);
}
catch (Throwable e)
{
System.out.println("ERROR: Sys.static"); // this line is printed
e.printStackTrace(); // !!! NPE occurs in the Err.toStr()
throw new RuntimeException("Cannot boot fan::Sys - " + e.toString());
}
Err.type() implementations usually returns static fields from the Sys class, but if the exception occurred the static fields were not initialized, so type() return null, and type().qname() in the toStr() throws NPE.
The patch:
diff -r e94fdf58964c src/sys/java/fan/sys/Err.java
--- a/src/sys/java/fan/sys/Err.java Sun Oct 18 10:19:31 2009 -0400
+++ b/src/sys/java/fan/sys/Err.java Mon Oct 19 11:34:11 2009 +0700
@@ -133,12 +133,18 @@
return Sys.ErrType;
}
+ private String typename()
+ {
+ final Type type = type();
+ return type != null ? type.qname() : getClass().getName();
+ }
+
public String toStr()
{
if (message == null)
- return type().qname();
+ return typename();
else
- return type().qname() + ": " + message;
+ return typename() + ": " + message;
}
//////////////////////////////////////////////////////////////////////////
alex_panchenko Mon 19 Oct 2009
Hello all,
If an exception occurs during sys.pod load then this problem is not reported correctly.
In Sys.java:
Err.type() implementations usually returns static fields from the Sys class, but if the exception occurred the static fields were not initialized, so type() return null, and type().qname() in the toStr() throws NPE.
The patch:
Thank you,
Alex
brian Tue 20 Oct 2009
Good idea!
I pushed a fix changeset
I decided to wrap with an exception just to be sure nothing fishy can happen.