If you raise a NullErr during initialization, you get a really weird error message.
class Bar
{
static Void main() {}
static const Int die := err
static Int err()
{
return 1.0 as Num
}
}
.
C:\Documents and Settings\malonm\Desktop>fan Bar.fan
java.lang.ExceptionInInitializerError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fan.sys.Method.invoke(Method.java:536)
at fan.sys.Method$MethodFunc.callList(Method.java:182)
at fan.sys.Method.callList(Method.java:147)
at fanx.tools.Fan.callMain(Fan.java:135)
at fanx.tools.Fan.executeFile(Fan.java:88)
at fanx.tools.Fan.execute(Fan.java:34)
at fanx.tools.Fan.run(Fan.java:235)
at fanx.tools.Fan.main(Fan.java:273)
Caused by: java.lang.ClassCastException: java.math.BigDecimal cannot be cast to
java.lang.Long
at fan.Bar_0.Bar.err(/C:/Documents and Settings/malonm/Desktop/Bar.fan:8
)
at fan.Bar_0.Bar.<clinit>(/C:/Documents and Settings/malonm/Desktop/Bar.
fan:4)
... 12 more
I'm wondering if there's any way to clean that up.
EDIT: After correcting this error in my code, I ran across the same problem again. This time, it was this:
class Bar
{
static Void main() {}
static const Bar[] die := err
static Bar[] err()
{
b0 := Bar()
return Bar[b0]
}
}
.
C:\Documents and Settings\malonm\Desktop>fan Bar.fan
java.lang.ExceptionInInitializerError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fan.sys.Method.invoke(Method.java:536)
at fan.sys.Method$MethodFunc.callList(Method.java:182)
at fan.sys.Method.callList(Method.java:147)
at fanx.tools.Fan.callMain(Fan.java:135)
at fanx.tools.Fan.executeFile(Fan.java:88)
at fanx.tools.Fan.execute(Fan.java:34)
at fanx.tools.Fan.run(Fan.java:235)
at fanx.tools.Fan.main(Fan.java:273)
Caused by: sys::NotImmutableErr: Item [0] not immutable Bar_0::Bar
at fan.sys.NotImmutableErr.<init>(NotImmutableErr.java:39)
at fan.sys.NotImmutableErr.make(NotImmutableErr.java:25)
at fan.sys.NotImmutableErr.make(NotImmutableErr.java:22)
at fan.sys.List.toImmutable(List.java:1244)
at fan.sys.FanObj.toImmutable(FanObj.java:117)
at fan.Bar_0.Bar.<clinit>(/C:/Documents and Settings/malonm/Desktop/Bar.
fan:4)
... 12 more
This time, it was cause by the fact Bar isn't a const class.
It took me a while to track these problems down. I'm wondering what we might be able to do to improve the error messages.
brianWed 10 Mar 2010
Tracking down class initializations is exceptionally difficult in Java because for some reason you often don't actually get the full dump.
One thing I've considered is wrapping every static initializer with a catch block and exception dump .
tacticsWed 10 Mar 2010
One thing I've considered is wrapping every static initializer with a catch block and exception dump .
This seems like it would be more useful than the current behavior.
KevinKelleyWed 10 Mar 2010
Yeah, that might help; these are hard errors to fix. I've redesigned away from statics several times, to make debugging easier/possible.
tactics Wed 10 Mar 2010
If you raise a
NullErr
during initialization, you get a really weird error message..
I'm wondering if there's any way to clean that up.
EDIT: After correcting this error in my code, I ran across the same problem again. This time, it was this:
.
This time, it was cause by the fact
Bar
isn't aconst
class.It took me a while to track these problems down. I'm wondering what we might be able to do to improve the error messages.
brian Wed 10 Mar 2010
Tracking down class initializations is exceptionally difficult in Java because for some reason you often don't actually get the full dump.
One thing I've considered is wrapping every static initializer with a catch block and exception dump .
tactics Wed 10 Mar 2010
This seems like it would be more useful than the current behavior.
KevinKelley Wed 10 Mar 2010
Yeah, that might help; these are hard errors to fix. I've redesigned away from statics several times, to make debugging easier/possible.