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

 
 

bug #30661: Reflection methods return strange object.

Submitter:  None
Submitted:  Thu 05 Aug 2010 07:00:43 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Unexpected result Status:  Invalid
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group administrator
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 Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-10-02 bothner Open/ClosedOpen Closed
    2010-10-02 bothner StatusNone Invalid
        Assigned toNone bothner

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code