bugKawa - Bugs: bug #30661, Reflection methods return strange...

 
 

bug #30661: Reflection methods return strange object.

Submitted by:  None
Submitted on:  Thu 05 Aug 2010 07:00:43 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Unexpected resultStatus: Invalid
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 02 Oct 2010 12:41:56 AM UTC, comment #1:

(Sorry for not answering this sooner.)

This result:
class [Ljava.lang.reflect.Method;
from
(get-class (get-methods 'foo))
is indeed as expected. The result (get-methods 'foo) is an array of java.lang.reflect.Method instances, so get-class of the resuot is java.lang.reflect.Method[] in Java syntax. However, the toString method of java.lang.Class uses java.lang.Class#getName for pretty bogus but historical reasons. Check the JavaDoc for java.lang.Class#getName.

"(get-methods (get-methods 'x))
returns
=> []
invoking getDeclaredMethods should return list of <java.lang.reflect.Method> objects."

No, it returns a (Java) array of java.lang.reflect.Method objects. And in this case its an empty array, since the argument array type has no methods (except those inherited from Object).

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Thu 05 Aug 2010 07:00:43 PM UTC, original submission:

When I use reflection like this

(define (get-class object)
(invoke object 'getClass))

(define (get-methods object)
(invoke (get-class object) 'getDeclaredMethods))

(get-methods 'foo)

I get this:

[public java.lang.Object gnu.mapping.SimpleSymbol.readResolve() throws java.io.ObjectStreamException
public void gnu.mapping.SimpleSymbol.writeExternal(java.io.ObjectOutput) throws java.io.IOException
public void gnu.mapping.SimpleSymbol.readExternal(java.io.ObjectInput) throws java.io.IOException,java.lang.ClassNotFoundException]

And when I ask for the type of value returned by get-methods

(get-class (get-methods 'foo))
I've got
=> class [Ljava.lang.reflect.Method;

Insted list, java array or iterator.

And list of methods of value of methods

(get-methods (get-methods 'x))
returns
=> []
invoking getDeclaredMethods should return list of <java.lang.reflect.Method> objects.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bothner (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 02 Oct 2010 01:51:39 AM UTCbothnerOpen/ClosedOpen=>Closed
    Sat 02 Oct 2010 12:41:56 AM UTCbothnerStatusNone=>Invalid
      Assigned toNone=>bothner

    Back to the top


    Powered by Savane 3.1-cleanup1