Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Parameter names
Parameter names [message #256262] Tue, 09 September 2008 22:17 Go to next message
Eclipse UserFriend
Given a method invocation, can I get the names of the parameters of the
invoked method?

I would like to get such names even from methods only found in
classfiles/bytecode and not necessarily available in source. Granted such
methods would have the debugging information.

Thanks in advance.
Re: Parameter names [message #256266 is a reply to message #256262] Wed, 10 September 2008 04:03 Go to previous messageGo to next message
Eclipse UserFriend
Do you mean the names of the arguments passed to the method invocation? If
so something like the following should work:

private String getMethodArguments(MethodInvocation method) {
StringBuilder args = new StringBuilder();
for (int i = 0; i < method.arguments().size(); i++) {
args.append(((Expression) method.arguments().get(i)).toString());
if (i < method.arguments().size() - 1) {
args.append(", ");
}
}
return args.toString();
}
Re: Parameter names [message #256278 is a reply to message #256266] Wed, 10 September 2008 11:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

> Do you mean the names of the arguments passed to the method invocation?
I mean the names of the parameters of the invoked method.

Given a method invocation: GUI.createWindow(1, 2), I would like to see
that 1 is passed to parameter named 'length' and 2 to 'width'. This is
provided that the declaration is: Window createWindow(int length, int
width); but we may only have the bytecode for such declaration (but with
debugging information).
Re: Parameter names [message #256333 is a reply to message #256278] Fri, 12 September 2008 03:51 Go to previous message
Eclipse UserFriend
Originally posted by: none.domain.invalid

Mahmood Ali a écrit :
> Hi,
>
>> Do you mean the names of the arguments passed to the method invocation?
> I mean the names of the parameters of the invoked method.
>
> Given a method invocation: GUI.createWindow(1, 2), I would like to see
> that 1 is passed to parameter named 'length' and 2 to 'width'. This is
> provided that the declaration is: Window createWindow(int length, int
> width); but we may only have the bytecode for such declaration (but with
> debugging information).

Seems overly complicated. Just get the javadocs.
Previous Topic:How to contribute popup menu item to Package Explorer
Next Topic:How to programatically rename a Java project?
Goto Forum:
  


Current Time: Sun Jul 27 09:19:09 EDT 2025

Powered by FUDForum. Page generated in 0.25719 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top