• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reflection

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a problem with reflection. I keep getting a NullPointerException and can't figure out why.
It is happening when I call this:


I can't figure out what the problem is. I had this reflection working, and then I made some changes to how the argument array was created. In the end, the argarray is the same.
Any ideas?
 
Stephen Murphy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, the API for the method class says that a NullPointerException is thrown if the object in the first argument is null. I have tested for this, and it is not null.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Plain and simple: something is null. The stack trace would go along way toward pinning this down. If the top frame is in this file, on this line, then "method" is null. If it's an InvocationTargetException and the contained exception is null, then one of the arguments is probably null and shouldn't be. If the top frame is in invoke() itself, then one of the two arguments to invoke() is likely null, or your passing a "null" for a primitive type in "argArray".

If you can't puzzle it out this way, putting in a bunch of print statements to print your variables would be a help.
 
Stephen Murphy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. Turns out that argArray was null. It was the very last thing I checked. Apparently I screwed up the loop that build the argArray and it was just filling up with nulls.

Thanks for the reply.
 
reply
    Bookmark Topic Watch Topic
  • New Topic