Method argument names

Hey, quick question, and unfortunately I think I know the answer. I'm no expert at using reflection, but from what I can tell thus far, it is possible to get the Class name, the names of the fields in the class, and the method names. I need the names of the arguments in the methods. i.e. as a simple example:    public double quotient(double dividend, double divisor) {
        return dividend/divisor;
    }I can get the method name, the return type and the types of the arguments, but I need the actual names of the arguments. In this case I would need "dividend" and "divisor". Is this possible, and if so please let me know how?
Thanks,
Steve

This is not possible with 1.5. I heared some roumor that 1.6 will provide access to argument names.

Similar Messages

  • Getting method arguments as hasmap

    Hi,
    can I get a method arguments in hashtable ? for example
    public void methodA(integer arg1,string arg2, integer arg3)
    so,
    is there any method in java that return a hashtable contains all method arguments , while running methodA.
    hashTable would be like this :
    arg1 1
    arg2 'a'
    arg3 5

    Bender_R. wrote:
    If you really need it, you can do it using Spring AOP. See AOP
    Edited by: Bender_R. on Oct 29, 2009 11:47 AMWhich won't give parameter names. And is unnecessary anyway, since you could just use a dynamic proxy without having to have all the Spring dependencies present

  • The arguments' name change when I re-import the model

    Hello
    Some times, when I re-import Java bean model in developer studio (SAP NetWeaver 7.1 Composition Environment SP06 PAT0001), the arguments' name change to arg0, arg1u2026. 
    For example:
    I have some method in the EJB model, such:
    public String getCustomerName( String customerId);
    Some times the reimport is ok, but some times the reimport changes the arguments' name, like:
    public String getCustomerName( String arg0);
    What are Iu2019m doing wrong?
    Regards
    Janeth

    Hi everybody,
    i have the same problem. i also tried to reimport different ejbs into different wd-projects. allways the same problem. and i didn't found a workaround for this.
    i also deleted the model and made a complete new import. same result.
    i also created a new fresh web-dynpro dc  and created a new model there, also same result.
    I assume that it maybee has something to do with an nwds-update i made last week (so between last model-import and new model-import).
    does anybody has a solution for this so far?
    regards
    matthias

  • Find out method argument values at run time

    Hi,
    I am looking to find out the argument names and values of a method at run time. (This would allow for instance to automatically log argument names and values without writing tedious code).
    The following thread did not seem to answer this problem
    http://forum.java.sun.com/thread.jspa?forumID=4&threadID=411455
    Any suggestions welcomed
    Ben

    As there is no Method-Object representing the current method call, I doubt you will get hands on the arguments passed to the method other than referencing them or building a framework "on top" (as, e.g., AspectJ). Also, Method in reflections does not hold the names of parameters, so it will be difficult to automatically print information on more than the signature.
    The following is a not very robust, little play-around code for logging. Maybe it delivers enough information for some situations:
    public class Test {
        void test(String arg0, int arg1) {
            log(new MethodGetter(){}.get(), arg0, arg1);
        public static void main(String[] args) {
            new Test().test("zero", 1);
        public static final void log(Method method, Object ... args) {
            final StringBuilder builder = new StringBuilder();
            builder.append(method.getDeclaringClass().getSimpleName()).append('.');
            builder.append(method.getName()).append('(');
            final Class<?>[] parameterTypes = method.getParameterTypes();
            for (int index = 0; index < parameterTypes.length; index++) {
                if (index > 0) {
                    builder.append(", ");
                builder.append('(').append(parameterTypes[index].getSimpleName()).append(") ");
                if (index < args.length) {
                    builder.append(args[index]);
                } else {
                    builder.append("null");
            builder.append(");");
            System.out.println(builder.toString());
        public static abstract class MethodGetter {
            public Method get() {
                return getClass().getEnclosingMethod();
    }It will print the following:
    Test.test((String) zero, (int) 1);
    Note that MethodGetter and log and main are enclosed for test purpose only.

  • Is there any way to call a method by name?

    Hi there,
    Is there any way to call a method by name?
    e.g. myobject.whatIAmLookingFor("the_name_of_a_myobject's_method",param1,param2,...);
    Thanx in advance

    Is there any way to call a method by name?
    Yes:
    <looking at his paint(Graphics g) method>
    Hey Sam! Commere Sam! Das a good boy!

  • Read only method arguments

    Can I make method arguments read only?? I want to send an object to a method and make it read only. i dont want a method to change public varables of the mthod argument object.
    Can anyone help me on this??
    Thanks,
    Vaijayanti

    Not possible, but you can pass a copy of the object, so that even if it's changed the changes aren't reflected to the original object.

  • [svn:fx-trunk] 7825: Updating sample Java formatter for Eclipse projects to stop reformatting method arguments .

    Revision: 7825
    Author:   [email protected]
    Date:     2009-06-13 14:17:47 -0700 (Sat, 13 Jun 2009)
    Log Message:
    Updating sample Java formatter for Eclipse projects to stop reformatting method arguments.
    QA: No
    Doc: No
    Modified Paths:
        flex/sdk/trunk/development/eclipse/java/formatter.xml

    If you're still using Buckminster 3.6, I strongly suggest switching to 3.7 - it has a number of bug fixes and improvements. This applies to both headless, and the IDE (assuming Eclipse 3.7 Indigo).
    Matthew

  • Method parameter names

    I'm using jwsdp-2.0 and jdk1.4
    my question is
    How can i change method parameter names that generated on WSDL file ?
    when I'm trying to use (-g) option with javac command i have the same result.

    The parameter names aren't included in the bytecode.
    Therefor it is impossible to get them.
    Not with reflection, not with other tools.
    I'm afraid, but you'll have to scan the source.

  • Calling method's name

    Hi all,
    Can anybody please help me to find out the name of the calling method and also which class does it belond.
    e.g.,
    In class User,
    getAll(...)
    getDetails(...) call is made
    In another class ACF
    public void getDetails(..)
    definition is present
    Is there any method which can be used in class ACF so that the calling method's name (i.e getAll() ) and class name (i.e. User) can be found out??????

    If what your asking is how do I know what object called the method then you can use BCEL to instrument the invokevirtual instructions in the class.
    If you want to know what method called a method then instrument invokestatic instructions

  • Invoking methods by name

    Is it possible (and if so how) to invoke a method using a name stored in a variable?
    private void thisMethod(){
    is normally run by using the method name:
    thisMethod();
    or
    this.thisMethod();
    But if there are a number of methods (method1, method2, method3 say) and the choice of which method to use is derived from some source (in my case as a jsp request parameter), is there some way of saying "run the method whose name is stored in variable methodName"?
    The alternative is of course to use a lot of if ... else if statements, but there are situations where even that does not help very much.
    Clearly what I am asking for is some kind of late binding, which should not be too hard for any language which can implement run time polymorphism, but how?
    Good ideas and information welcome.
    David

    If you know the class then you can use reflection to do the job. You can get the methods names using instance.getClass().getDeclaredMethods(...);
    If the methods have the same interface but differ in implementation then you could create an interface, have a number of classes implement the interface, then scan the classpath for classes that implement the interface.
    there's probably more
    Dave

  • Creating arrays in method argument

    this words fine
    int[] f = {1,2,3,4};but when i try make it into one line, for example for usage as arguments to a method, it does not compile
    class test {
         public static void a(int[] in) {};
         public static void main (String[] args) {
              a( (int[]) {1,2,3,4 } );
    };i know i could just declare the array before hand, but it in my case it involves calling a super constructor, which must be the first line in the function.
    help would be appreicated

    Hi,
    a(new int[] { 1,2,3,4,});
    /Kaj

  • ADFBC Where to define labels for custom Application Module method arguments

    I was wondering if there was a "good place" to define these labels in ADF Business Components. I can just change them for the UI for my current project, but I thinking there might be a better way.
    Thanks,
    Brian

    Hi,
    I think you can't in BC, but you can in ADF. If you drag a method onto the client then it creates a method binding with argument itemes below. In addition, look in the executable section, it creates variables for each. This is where you can define labels so that they can be translated
    Frank

  • Array as method argument

    Is there anyway to pass an Array as argument without declare an array variable before?
    Example:
    public class MyClass
    public MyClass
    myMethod( HOW CAN I PASS AN ARRAY HERE !);
    public void myMethod(String[] myArray)
    // The method body ;

    Is there anyway to pass an Array as argument without declare an array variable before?what's the point of passing the array then?
    when you passs the array..you want to send some information and get someinformation back
    by not decalring the variable before passing in the array..it's just makes no sense
    mind as well rewrite the method to taks no argument
    but here..you do it like this
    myMethod(new String[]) // not initialized array of String
    myMethod(null); // send in a null object

  • Remote method arguments (RMI)

    Configuration:
    OC4J Release 2
    JDeveloper 9i RC
    Problem:
    I get a "ClassNotFoundException" when passing objects as arguments to a remote method.
    The object being passed implements an interface. The interface extends "Serializable" and it is available on the server (where the RMI class resides).
    Appreciate any help on this.
    Thanks,
    Ranga

    Found the solution. Thanx.

  • Getting method parameter names

    Hello everyone,
    I need to get parameter names of class methods. I checked the API for java.lang.reflect.Method, I found that it gives the types but not the names.
    The following should print parameter names but it displays nulls for parameter descriptors. Any idea why ?
    import java.beans.BeanInfo;
    import java.beans.Introspector;
    import java.beans.IntrospectionException;
    import java.beans.MethodDescriptor;
    public class pd
    public static void main( String[] args ) throws IntrospectionException
    BeanInfo info = Introspector.getBeanInfo( javax.swing.JLabel.class,javax.swing.JComponent.class );
    System.out.println("MethodDescriptors:");
    for ( MethodDescriptor md : info.getMethodDescriptors() )
          System.out.println( md.getName() );
          System.out.println("ParameterDescriptors:"+md.getParameterDescriptors());
    }

    Knowing the "true name" of the parameter gives one power over it?
    I suppose one could want to create dynamically generated documentation on arbitrary compiled code, or create some user interface to analyze objects/classes at runtime and call methods directly on them through some generically generated input fields. Perhaps as some sort of learning tool.
    In that case, it would be useful to know the parameter names when there's multiple, particularly of the same type. The names ideally would indicate their use... although you can't always assume that.
    Not that I can offer much help if the reflection classes don't provide for it already.

Maybe you are looking for

  • ALE Change pointer idocs generated in wrong sequence

    We are using the serialization group to generate the MATMAS and CLFMAS idocs with the sequence MATMAS generated first and then CLFMAS. Normally,this seems to work fine with the idocs generated in the right sequence. However, during a period of every

  • Problem in F101(very urgent)

    Hi, We are facing some problem in F101(BALANCE SHEET SUPPLEMENT),after giving the inputs when we execute the transaction ,it shows some entries, then we click on posting button ,and batch input session creates,then in SM35 we select our batch input s

  • Can't uninstall AIR - XP?

    Hi guys, I'm trying to test my badge installer and have seen that it is not working if the user does not have AIR installed. It's able to install the AIR file correctly, but on other machines without the AIR runtime it fails. Now to debug this and fi

  • Beginner question about Applescript

    Hello, I'de like to know two things : - can I use Applescript on an application which does not have any dictionary ? - do you think it would be possible to make a script which would detect the opening of a window on this application, and automaticall

  • Error #1009 Please Help

    Hey Im new to Flash and Actionscript, I've only been using it for a week or so and get this error message: TypeError: Error #1009: Cannot access a property or method of a null object reference.     at Untitled_fla::MainTimeline/__setProp_imageloader_