Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

method argument names

Thread view: 
Chez - 24 Nov 2006 11:30 GMT
I'm looking to get method argument names with reflection or any other way
..for ex:

public String getAddress(String name, int age)

I'd like to get the argument names "name" and "age".

Is this possible ...? and if yes, how ?

regards,
Chez
Ingo R. Homann - 24 Nov 2006 12:14 GMT
Hi,

> I'm looking to get method argument names with reflection or any other way
> ..for ex:
[quoted text clipped - 4 lines]
>
> Is this possible ...? and if yes, how ?

No.

Just of curiosity: Why do you want that?

Ciao,
Ingo
Tomek - 24 Nov 2006 12:29 GMT
Ingo R. Homann napisal(a):
> Hi,
>
[quoted text clipped - 8 lines]
>
> No.

Yes, its possible and some webservice frameworks ( like XFire and Axis
) do it. But it can only be done if your class i compiled with debug
info ( don't works on interfaces as i remember , only only on classes )

> Just of curiosity: Why do you want that?
>
> Ciao,
> Ingo
sgoo - 24 Nov 2006 12:57 GMT
> > > Is this possible ...? and if yes, how ?
>
> > No.
> Yes, its possible and some webservice frameworks ( like XFire and Axis
> ) do it. But it can only be done if your class i compiled with debug
> info ( don't works on interfaces as i remember , only only on classes )

which means, still NO.
Tomek - 24 Nov 2006 13:21 GMT
sgoo napisal(a):
> > > > Is this possible ...? and if yes, how ?
> >
[quoted text clipped - 4 lines]
>
> which means, still NO.

which means, yes , but in some cases :)
Tor Iver Wilhelmsen - 24 Nov 2006 16:51 GMT
> which means, yes , but in some cases :)

Still means "no" for reflection but "yes" for the debugger API.
Daniel Pitts - 24 Nov 2006 18:39 GMT
> I'm looking to get method argument names with reflection or any other way
> ..for ex:
[quoted text clipped - 7 lines]
> regards,
> Chez

Not easily, but I would suggest finding some way other than reflection
if possible.  Reflection is often abused by people who have experience
with function pointers in C.  There are likely other, better ways to do
what you intend.

If you let is know WHY you want to do it, we might be able to suggest a
better alternative.

Good luck.
sgoo - 25 Nov 2006 01:49 GMT
Well, if the compiler has completely remove the name info (in the case
of non-debug output), then there's no way to get it back.
Daniel Pitts - 25 Nov 2006 19:15 GMT
> Well, if the compiler has completely remove the name info (in the case
> of non-debug output), then there's no way to get it back.

Hence, the not easily.

It would be possible if debug output was enabled, or if they used some
other technique to save the parameter names.  The point of my post was
that the OP might be trying to do something that could be done another
simpler way.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.