This is something I just found out, and I figured I'd blog about it for those that might come across this in the future.
I'm writing some code in a project (JZBot specifically, http://jzbot.googlecode.com) that uses java.lang.reflect.Proxy. At one point, I was calling a method on a proxy instance, and it was throwing a NullPointerException. The weird thing about this was that the NullPointerException was being thrown from within the proxy instance itself, not from the InvocationHandler that it is supposed to call. Other methods on the proxy worked, indicating that there wasn't some error with the invocation handler somehow being set to null.
Eventually, I found the problem: I had declared the method on the interface that the proxy implemented to return a boolean, but the invocation handler was returning null. The auto-unboxing that was being done by the proxy instance internally was messing things up. I changed the method's return type to void (which is what it should have been), and everything worked.
This is yet another example of where to watch out for autoboxing and unboxing. Admittedly, it would be more helpful if the NPE had a message stating something like, for example, "null can't be unboxed to a boolean", which would most likely have saved me quite a bit of time. Oh well.
17 comments:
Thanks for this, I found it very helpful! (In my case, the method was hashCode, so the conversion was from Integer to int rather than Boolean to boolean, but, same idea.)
Thanks for posting this!
Thanks for posting this! I had the same problem and was wondering and wondering... ;-)
Thank you :)
Thanks for posting this blog entry. I had a similar problem that I was banging my head against. I couldn't change the method signature to void, in my case, but returning a proper default value (0 or false) instead of null fixed the problem.
Thank you for your sharing and I want to more updates for my research..
Appium Training in Chennai
Appium Certification in Chennai
Pega Training in Chennai
Tableau Training in Chennai
Advanced Excel Training in Chennai
Spark Training in Chennai
Primavera Training in Chennai
Unix Training in Chennai
Power BI Training in Chennai
Corporate Training in Chennai
Placement Training in Chennai
Good post. I learn something totally new and challenging on blog IS stumble upon everyday. It’s always helpful to read through articles from other authors and use a little something from their sites. Turkey tourism.You can check all Turkey tourism Guidelines Turkey through Turkey e-Visa website.
This is a very useful article… India etv visa fee depends on your visa type and your nationality
I appreciate your work... Thanks for sharing... There is good news for international travelers. The Indian government restored the Indian tourism sector and also India tourist visa for the long term, which means I have more time to explore India.
Hii friends, I wanted to write a little Info related to Visa. Are you interested in traveling to any country? Yes, you can apply for a visa online. You can fill out your visa application form online within 5 to 10 minutes via our Visacent website. We offer visas to citizens of over 190 countries. You can read more info about visas via our website.
"The quality of your writing and the logical flow of your ideas are remarkable. This post is a fantastic resource, and your passion for the subject shines through." Do you know Egypt Introduces New Residency Fees, now need to furnish proof of converting all relevant fees from U.S. dollars or their equivalent foreign currencies into Egyptian pounds, as per the new regulation.
Your writing is truly remarkable! This paragraph is a shining example of your talent, and I'm eagerly looking forward to more posts of this caliber. Stay informed with the most recent Japan vaccine guidelines.Japan had introduced strict vaccine requirements for travelers.
Your blog entry resonated deeply with my own experiences, highlighting the depth of human connections and the meaningful impact of simple acts of kindness."This is information I believe is worth sharing."
"Turkey entry requirements vary by nationality. It's essential to research and comply with the specific visa and documentation regulations before traveling. Adhering to Turkey's entry requirements ensures a smooth and enjoyable visit to this beautiful country."
You're knocking it out of the park with your reporting, and I'm continually amazed by your professionalism and expertise. Keep up the excellent work, and know that I'm here to support you.
The India tourist visa fee for USA citizens varies depending on the duration of the visa and the type of entry required. As of the latest information available, the fee structure typically includes different tiers for various visa durations, such as 10 years, 5 years, or shorter stays.
Your insights are valuable and easy to understand, making complex subjects clear and engaging. It feels like learning from a knowledgeable friend. I'm saving your content for future reference and can't wait for more great work! Apply for your Cameroon visa application easily with quick access to the application form. Complete it, attach the necessary documents, and submit. The simple interface and clear instructions make the process smooth, helping you get ready for your trip to Cameroon quickly and efficiently.
Discovering this post feels like stumbling upon a treasure trove of wisdom amidst the vast digital sea! Your knack for simplifying complex concepts is truly admirable. Reading through, I felt like I was embarking on a journey of enlightenment. Planning a trip to Saudi Arabia and wondering about How much is Saudi tourist visa for US citizens? You're not alone! As of the latest updates, the Saudi tourist visa fee for US citizens varies depending on the duration of stay. And regarding more Information visit Our website.
The thorough analysis and the straightforwardness with which you explained complicated concepts were impressive. I particularly appreciated the real-world examples that brought a practical aspect to the discussion. Your writing is both engaging and informative, capturing my attention from beginning to end. How long does it take to get an Ethiopian e-Visa from Israel? The processing time for an Ethiopian e-Visa from Israel typically ranges from one to three business days. Applicants need to complete an online form, submit a valid passport, a recent passport-sized photo, and pay the visa fee. Once approved, the e-Visa is electronically issued and sent via email. Ensure your passport is valid for at least six months beyond your intended date of entry into Ethiopia.
Post a Comment