That doesn't explain why the line number is listed as 0.
Is that expected?
The stack trace does not appear to be any more helpful anyway:
user=> (let [listener (new-listener 8888)]
(.accept listener))
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> (.printStackTrace *e)
java.lang.NullPointerException (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:4118)
at clojure.lang.Repl.main(Repl.java:93)
Caused by: java.lang.NullPointerException
at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:253)
at user$eval__40.invoke(Unknown Source)
at clojure.lang.Compiler.eval(Compiler.java:4107)
... 1 more
nil
--
Michael Wood <esio...@gmail.com>
On Wed, Nov 26, 2008 at 6:27 AM, Chris Turner <J.Chris...@gmail.com> wrote:
>
> On Nov 24, 7:38 am, "Michael Wood" <esiot...@gmail.com> wrote:
>> On Mon, Nov 24, 2008 at 4:45 PM, Stuart Sierra
>>
>> <the.stuart.sie...@gmail.com> wrote:
>>
>> > If you're running this at the REPL, in recent versions only the name
>> > of the exception is printed. If you want the full backtrace, do:
>> > (.printStackTrace *e)
>>
>> That doesn't explain why the line number is listed as 0.
>>
>> Is that expected?
[...]
> The reason the line number is 0 is the NPE happens in the REPL... (new-
> listener 8888) is not throwing the exception, it's just returning
> null. The NPE happens on the next line: (.accept listener) where
> listener is now set to null.
I still don't see why it's line 0 :) I realise that (new-listener)
has nothing to do with it really and that it is the null pointer
dereference that causes this, but surely it is not on
NO_SOURCE_FILE:0. If this is expected on the REPL for some reason,
then take a look at Timothy's original message in this thread. He was
loading it from test.clj and the exception was reported on test.clj:0.
On a related note, if I try to evaluate a nonexistent symbol at the
REPL it always seems to report it as line 0, whereas if I try to
evaluate a nonexistent function it is reported correctly:
$ clj
Clojure
user=> blah
java.lang.Exception: Unable to resolve symbol: blah in this context
(NO_SOURCE_FILE:0)
user=> blah
java.lang.Exception: Unable to resolve symbol: blah in this context
(NO_SOURCE_FILE:0)
user=> blah
java.lang.Exception: Unable to resolve symbol: blah in this context
(NO_SOURCE_FILE:0)
user=> (blah)
java.lang.Exception: Unable to resolve symbol: blah in this context
(NO_SOURCE_FILE:4)
user=>
This is with r1121.
--
Michael Wood <esio...@gmail.com>