Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Addez

Thread: Reflection used method with multiple params claims that the 2nd param is null.

  1. #1
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default Reflection used method with multiple params claims that the 2nd param is null.

    Hi!

    Im using some reflection for awsome purpuses :P
    Anyways, I got this part that executes the method:
    PHP Code:
    Object[] input = getInputs();
    
    			System.out.println("Inputs: ");
    			for (Object o : input) {
    				System.out.println(o);
    			}
    			Class cl = object.getClass();
    
    			Method mthd = cl.getMethod(methodName, classes);
    
    			Object output = mthd.invoke(object, input);
    			System.out.println(output);
    The thing I get out is this:
    Java Code:
    Inputs: 
    (20.0, 30.0)
    0
    java.lang.NoSuchMethodException: xcomp.Unit.getOb(javax.vecmath.Vector2f, null)
    As you might see, it says the second param is null. But as you also may see, I just printed all params, and 0 is the 2nd param. So it is not null.

    Why does the method claim that the second param is null?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Reflection used method with multiple params claims that the 2nd param is null.

    Quote Originally Posted by Addez View Post
    Hi!

    Im using some reflection for awsome purpuses :P
    Anyways, I got this part that executes the method:
    PHP Code:
    Object[] input = getInputs();
    
    			System.out.println("Inputs: ");
    			for (Object o : input) {
    				System.out.println(o);
    			}
    			Class cl = object.getClass();
    
    			Method mthd = cl.getMethod(methodName, classes);
    
    			Object output = mthd.invoke(object, input);
    			System.out.println(output);
    The thing I get out is this:
    Java Code:
    Inputs: 
    (20.0, 30.0)
    0
    java.lang.NoSuchMethodException: xcomp.Unit.getOb(javax.vecmath.Vector2f, null)
    As you might see, it says the second param is null. But as you also may see, I just printed all params, and 0 is the 2nd param. So it is not null.

    Why does the method claim that the second param is null?
    You're making a wrong assumption here. The key is which line is throwing the exception above? That will help you fix your bad assumption and figure out a solution.

    If my post doesn't help, then let's walk through it, but first indicate which line is causing the exception above.
    Last edited by Fubarable; 09-17-2011 at 09:57 PM.

  3. #3
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default Re: Reflection used method with multiple params claims that the 2nd param is null.

    Indeed my very understanding friend :D
    The problem was in a total other part! Would never had guessed that!
    Thanks alot pal! It works great now :)
    Fubarable likes this.

Similar Threads

  1. hiding passed parameters using window.location.href = 'params' method
    By kulangotski in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 07-01-2011, 12:49 PM
  2. calling super method via reflection
    By oida in forum Advanced Java
    Replies: 5
    Last Post: 01-22-2011, 12:00 PM
  3. reflection invoke method
    By pprl in forum New To Java
    Replies: 12
    Last Post: 11-16-2010, 05:43 PM
  4. Display part of matching method using Reflection
    By finder255 in forum Advanced Java
    Replies: 0
    Last Post: 09-23-2010, 08:04 PM
  5. Getting method names using Reflection
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-24-2008, 03:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •