<< Interesting technote on maximum execution time of LotusScript agents | Home | Show 'n Tell Thursday: Automatically insert signature in the Notes/Domino 6/7 forum (22 June 2006) >>

Java in Notes/Domino Explained: Can I cast a null pointer?

In short - yes you can. There is nothing that prevents you from compiling the following:

String s1 = (String)null;

I even think you'll have to do it to make your code compile for one for the methods of lotus.domino-package. I can't of the top of my head remember which method it is, but there is one method where the compiler will force you to cast a null to a String. You'll also sometimes end up casting a null pointer when doing dynamic classloading.

I told you it would be a short post.



Re: Java in Notes/Domino Explained: Can I cast a null pointer?

Yep, you're correct. The method is NotesFactory.createSession().

When trying to create to connect through NRPC, you can use createsession(null, null, null). Unfortunately, this matches several different method signatures.

To let the compiler know which method you want to call, you have to cast all parameters to String, since the signature will be unique in this case. Thus:

Session s = NotesFactory.createSession((String) null, (String) null, (String) null);

Re: Java in Notes/Domino Explained: Can I cast a null pointer?

Thanks. Ever since writing the post I have been annoyed that I couldn't think of the method name... ;-)