Re: nullPointerException in abstract class



Matt Humphrey wrote:

I don't see how the line you've marked could cause a NullPointerException. Furthermore, if it did, it would certainly stop the program at that point.

The program might continue running if the exception is being caught somewhere else. This method would certainly terminate, however.


Looking at the source for Date(), it calls System.currentTimeMillis() to set a default date. Maybe the platform you have doesn't support currentTimeMillis() (it's a native method), or is having some error related to it?

I would try initializing birthDate with something besides the default constructor, see if that makes a different. Also, you might want to add some logging and error trapping. If the current error message isn't enough to allow you to figure out whats going on, add some of your own.

You could try birthDate = new Date( 0L ); which will avoid calling the native method, plus any overhead it has.
.



Relevant Pages

  • Re: JNIs throw new does not throw an exception
    ... the native method to the JVM, ... As I've gathered from all the posts here,and the JNI documentation, ... calling JNI functions after a call to ThrowNew, ... This means that posting an exception should preferably look like this: ...
    (comp.lang.java.programmer)
  • Re: nullPointerException in abstract class
    ... The program might continue running if the exception is being caught ... native method, ... I am new to Java although I have ... As to what caused the error; it bothers me that the program can report ...
    (comp.lang.java.programmer)
  • Re: JNIs throw new does not throw an exception
    ... I think your problem might be that after a ThrowNew, the native method ... returns true (or handle the exception in native code, ... But there's nothing wrong with getting a good head start. ...
    (comp.lang.java.programmer)
  • Re: JNIs throw new does not throw an exception
    ... I am returning from the native method immidiatly after "ThrowNew" ( ... I also put a break point in the exception object's c'tor on the Java ... "MyExceptionClass" object was constructed. ...
    (comp.lang.java.programmer)